package com.smartstate.autoMaticControl.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartstate.autoMaticControl.entity.Equipment;
import com.smartstate.autoMaticControl.entity.TreeNode;
import com.smartstate.autoMaticControl.vo.AlarmVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DeviceDisMapper  extends BaseMapper<Equipment>{


    List<Equipment> getList(@Param("dftype") Integer dftype,
                            @Param("dmtype") Integer dmtype,
                            @Param("type") Integer type);

    @Select("select  * from  equipment  where type=#{deviceType}")
    List<Equipment>  getListByType(@Param("deviceType") String  deviceType);

    @Select("select  * from  equipment  where  deviceId=#{deviceId}")
    Equipment getDeviceById(@Param("deviceId") String  id);

    List<Equipment> getConditioningSystemList(@Param("newTrendType") Integer newTrendType,
                                              @Param("blowingInType") Integer blowingInType,
                                              @Param("exhaustAirType") Integer exhaustAirType,
                                              @Param("type") Integer type);

    List<Equipment> getPureWaterAllList(@Param("pureWaterOneType") Integer pureWaterOneType,
                                        @Param("pureWaterTwoType") Integer pureWaterTwoType,
                                        @Param("pureWaterThreeType") Integer pureWaterThreeType,
                                        @Param("type") Integer type);

    List<TreeNode> getTreeList(String objId);

    /**
     * 查找出Root节点
     * @return
     */
    @Select("SELECT id FROM `objmoudel` WHERE `type` = '1' AND parentId = '0'")
    String getRootNode();

    List<Equipment> getTreeEquipments(String id);

    @Select("select i.objId from `objmiddle` i LEFT JOIN `objmoudel` o ON i.objId=o.`id` where i.deviceId=#{deviceId} and o.type=1")
    String selectObjIdByDeviceId(String deviceId);

    String getObjName(String deviceId);

    void addAlarm(AlarmVo alarmVo);

    @Select("select * from `alarm` where deviceId=#{deviceId} ")
    List<AlarmVo> getAlarm(String deviceId);
}
